import {
  get,
  post,
  put,
} from "./base_service"


/**
 * 城市代理相关接口
 *
 * allen  2021-08-24
 */




/**
 * 申请成为城市dialing
 * @param {*} data 
 */
const applyCityAgency = (data) => {
  return new Promise((resolve, reject) => {
    post("/proxy", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 获取代理详情回填
 */
const queryCityAgencyDetail = () => {
  return new Promise((resolve, reject) => {
    get("/proxy").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}



/**
 * 我的代理钱包
 */
const myWalletInfo = () => {
  return new Promise((resolve, reject) => {
    get("/user/query/wallet").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 收入明细
 */
const myIncomeList = (page, pageSize) => {
  return new Promise((resolve, reject) => {
    get("/user/query/wallet/record?page=" + page + "&pageSize=" + pageSize).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 提现申请
 * @param {*} money 
 */
const walletCashApply = (money) => {
  return new Promise((resolve, reject) => {
    get('/user/cash/money?money=' + money).
      then((data) => {
        if (data.code == 200) {
          resolve(data)
        } else {
          reject(data.msg)
        }
      })
  })
}

/**
 * 
 * 我的代理下属公司列表
 */
const myAgencyCompanyList = () => {
  return new Promise((resolve, reject) => {
    get('/user/cash?money=').
      then((data) => {
        if (data.code == 200) {
          resolve(data)
        } else {
          reject(data.msg)
        }
      })
  })
}












module.exports = {
  applyCityAgency,//申请成为城市dialing
  myWalletInfo,//我的代理钱包
  myIncomeList,//代理收益明细
  walletCashApply,//提现申请
  myAgencyCompanyList,//我的代理下属公司列表
  queryCityAgencyDetail,//代理详情回填
}
